
// 找出 arrB 不再 aarA 中的项
export function checkDiff(arrA, arrB, keys) {
  return arrB.filter(el => (arrA.map(el => el[keys])).indexOf(el[keys]) < 0 )
}

// 根据 key 去赋值
export function matchValue(arr, res) {
  for (var i in arr) {
      arr[i] = res[i]
  }
  return arr
}

// 深拷贝
export function deepCopy(obj) {
  var copy;
  if (null == obj || "object" != typeof obj) return obj;
  if (obj instanceof Date) {
      copy = new Date();
      copy.setTime(obj.getTime());
      return copy;
  }
  if (obj instanceof Array) {
      copy = [];
      for (var i = 0, len = obj.length; i < len; i++) {
          copy[i] = deepCopy(obj[i]);
      }
      return copy;
  }
  if (obj instanceof Object) {
      copy = {};
      for (var attr in obj) {
          if (obj.hasOwnProperty(attr)) copy[attr] = deepCopy(obj[attr]);
      }
      return copy;
  }
}